/*
 * \brief  Server-side de-marshaller of the CAP session interface
 * \author Norman Feske
 * \date   2006-07-10
 */

/*
 * Copyright (C) 2006-2009 Norman Feske
 * Genode Labs, Feske & Helmuth Systementwicklung GbR
 *
 * This file is part of the Genode OS framework, which is distributed
 * under the terms of the GNU General Public License version 2.
 */

#ifndef _INCLUDE__CAP_SESSION__SERVER_H_
#define _INCLUDE__CAP_SESSION__SERVER_H_

#include <cap_session/cap_session.h>
#include <base/server.h>

namespace Genode {

	class Cap_session_server : public Server_object, public Cap_session
	{
		public:

			int dispatch(int op, Ipc_istream &is, Ipc_ostream &os)
			{
				switch (op) {
				case ALLOC:
					{
						Capability ep;
						is >> ep;
						os << alloc(ep);
						return 0;
					}
				case FREE:
					{
						Capability cap;
						is >> cap;
						free(cap);
						return 0;
					}
				}
				return -1;
			}
	};
}

#endif /* _INCLUDE__CAP_SESSION__SERVER_H_ */
